/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025/6/13
 * Time: 04:13
 */

public class Solution {
    public static boolean isPalindrome(String string) {
        String string1 = string.toLowerCase();
        int i = 0;
        int j = string1.length() - 1;
        while (i < j) {
            while (i < j && !isNumberOrCharacter(string1.charAt(i))) {
                i++;
            }
            while (i < j && !isNumberOrCharacter(string1.charAt(j))) {
                j--;
            }
            if (string1.charAt(i) != string1.charAt(j)) {
                return false;
            }else {
                i++;
                j--;
            }
        }
        return true;
    }
    private static boolean isNumberOrCharacter(char c) {
        return c >= '0' && c <= '9' || c >= 'a' && c <= 'z';
    }
    public static void main(String[] args) {
        System.out.println(isPalindrome("A man, a plan, a canal: Panama"));
    }
}